

@extends('common.header')

<!-- 1.添加meta csrf_token -->
<meta name="csrf-token" content="{{ csrf_token() }}">  
<br/><br/><br/><br/>
<br/><br/>


<div class="col-xs-6 col-md-1">
</div>

<!-- 页面标记 -->
<div class="col-xs-6 col-md-1">
	<mark style="font-size:18px;">管理员列表</mark>
</div>
<div class="col-xs-12 col-sm-6 col-md-8">
	<!-- 搜索框 -->
	<form action="{{ url('/adminlist') }}" method='post' >
		<div class="col-lg-6" style="loat:left;margin-left:200px;" >
			<div class="input-group"  >
				
				{{ csrf_field() }}
				
				<input  type="text" name='keyword' class="form-control" placeholder="输入职工名 ...." value="{{ $request or '' }}" />
				
				<span class="input-group-btn">
					<input class="btn btn-success" type="submit" value="Go!" />
					<a class="btn btn-default" href="{{ url('/adminlist') }}" />清空条件</a>
				</span>
				
			</div>
		</div>
	</form>
</div>
<div class="col-xs-6 col-md-2">

</div>


<br/><br/><br/><br/>



<!-- 用户表格 -->
<div class="bs-example" data-example-id="hoverable-table" style="width:80%;margin:0 auto;">
    <table class="table table-hover">
		<thead>
			<tr>
			  <th></th>
			  <th></th>
			  <th>id</th>
			  <th>账号</th>
			  <th>上次登录时间</th>
			  <th><a href="{{ url('/adminer') }}" style="color:red; font-size:24px;">添加</a></th>
			  <th></th>
			</tr>
		</thead>
		<tbody>
			@forelse($admin as $user_info)
				<tr>
					<td></td>
					<td></td>
					<td>{{ $user_info->id }}</td>
					<td>{{ $user_info->name }}</td>
					<td>{{ $user_info->lasttime }}</td>
					<td>
						<a href="{{ url('/allauth') }}/{{ $user_info->id }}" style="font-size:18px;">分配权限</a>&nbsp;&nbsp;
						<a href="javascript:void(0);" style="font-size:18px;" onclick="deletes('{{ $user_info->id }}')" >删除</a>
					</td>
					<td></td>
				</tr>
			@empty
				<tr>
					<td scope="row"><h2>暂无数据</h2></td>
				</tr>
			@endforelse
		</tbody>
    </table>
</div>


<!-- 1.模态框 不要动 -->
<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
	<div class="modal-dialog modal-sm" role="document" id='show_info'  style="margin-top:80px;margin-left:45%;color:white;font-size:20px;">
	</div>
</div>

<!-- 分页 -->
<div style='text-align:center;'>
	{{ $admin->appends(['keyword'=>$request])->links() }}
</div>
<div class="badge" style="width:100%;text-align:center;font-size:18px;margin-bottom:70px;" >
		共{{ $admin->total() }}条数据
</div>



<script src=" {{ asset('./js/jquery-1.8.3.min.js') }} "></script>
<script>
	<!-- 2.设置全局ajax选项 -->
	$.ajaxSetup({
		headers: {
			'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
		}
	});
	var _token = $('meta[name="csrf-token"]').attr('content');
    //获取url
    var url = "{{ url('/delauth') }}";

    //执行删除
    function deletes(id){
        $.ajax({
            type:'post',
            url:url,
            data:{
                id:id,
                _token:_token
            },
            async:true,
            dataType:"json",
            success:function(msg){
                if(msg==1){
                    alert("操作成功");
                    window.location.reload();
                }
                if(msg==0){
                    alert("操作失败");
                    window.location.reload();
                }
            }
    }
)}
	// 执行 冻结 用户状态 
	function upStatus( user_id,status )
	{
		
		if( confirm('真的冻结此账户吗？') )
		{
			$.ajax({
				type:"post",
				url:"{{ url('/user/freeze') }}"+'/'+user_id,
				data:{status:status,_token:_token},
				async:true,    					
				dataType:"json",
				success:function(back){
					// 2.模态框 不要动
					$('#show_info').html( '' );
					$('#show_info').html( back['show_info'] );
					if( back['show_info']=='冻结成功' )
					{
						setTimeout(function(){
							location.reload(); 
						}, 1000);  
					}
					
					
				}
			});
		}else
		{
			location.reload();
			return false;
		}
		
	}
	
</script>


@extends('common.footer')